import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { VantResolver } from 'unplugin-vue-components/resolvers'
import path from 'path'

const __dirname = import.meta.dirname

export default defineConfig({
    server: {
        proxy: {
            '/api': {
                target: 'http://localhost:1102',
                changeOrigin: true,
                rewrite: (path) => path.replace(/^\/api/, ''),
            },
        },
    },
    plugins: [
        vue(),
        AutoImport({
            resolvers: [VantResolver()], // ✅ 官方 Resolver
        }),
        Components({
            resolvers: [VantResolver()], // ✅ 官方 Resolver
        }),
    ],
    resolve: {
        alias: {
            '@': path.resolve(__dirname, './src')
        }
    }
})
